package com.ibl.rover.lite.common.bean;


import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

public class UserBean extends BaseBean {

	@ColumnOrder(Order = 1)
	private String userName;
	@ColumnOrder(Order = 2)
	private String password;
	@ColumnOrder(Order = 3)
	private String streetAddress;
	@ColumnOrder(Order = 4)
	private String contact;
	@ColumnOrder(Order = 5)
	private String role;
	@ColumnOrder(Order = 6)
	private String cellNumber;

	private static AutomatedQueryStatement AUTO_GEN_QUERY;

	public static final String COL_USER_NAME = "USER_NAME";
	public static final String COL_PASSWORD = "PASSWORD";
	public static final String COL_STREET_ADDRESS = "STREET_ADDRESS";
	public static final String COL_CONTACT = "CONTACT";
	public static final String COL_ROLE = "ROLE";
	public static final String COL_CELL_NUMBER = "CELL_NUMBER";

	public static final int IDX_COL_USER_NAME = 1;
	public static final int IDX_COL_PASSWORD = 2;
	public static final int IDX_COL_STREET_ADDRESS = 3;
	public static final int IDX_COL_CONTACT = 4;
	public static final int IDX_COL_ROLE = 5;
	public static final int IDX_COL_CELL_NUMBER = 6;

	static {
		AUTO_GEN_QUERY = SQLiteDatabaseHelper
				.getAutoGeneratedStmts(UserBean.class);
	}

	public UserBean() {

	}

	@Override
	public void bind(SQLiteStatement sqlLiteStatement) {
		sqlLiteStatement.bindString(IDX_COL_USER_NAME, userName);
		sqlLiteStatement.bindString(IDX_COL_PASSWORD, password);
		sqlLiteStatement.bindString(IDX_COL_STREET_ADDRESS, streetAddress);
		sqlLiteStatement.bindString(IDX_COL_CONTACT, contact);
		sqlLiteStatement.bindString(IDX_COL_ROLE, role);
		sqlLiteStatement.bindString(IDX_COL_CELL_NUMBER, cellNumber);
	}

	@Override
	public <T extends BaseBean> T cursorBind(Cursor cursor) {
		UserBean userBean = new UserBean();
		userBean.set_id(cursor.getInt(IDX_COL_ID));
		userBean.setUserName(cursor.getString(IDX_COL_USER_NAME));
		userBean.setPassword(cursor.getString(IDX_COL_PASSWORD));
		userBean.setStreetAddress(cursor.getString(IDX_COL_STREET_ADDRESS));
		userBean.setContact(cursor.getString(IDX_COL_CONTACT));
		userBean.setRole(cursor.getString(IDX_COL_ROLE));
		userBean.setCellNumber(cursor.getString(IDX_COL_CELL_NUMBER));
		return (T) userBean;
	}

	@Override
	public <T extends BaseBean> T cursorInit(Cursor cursor) {
		this.set_id(cursor.getInt(IDX_COL_ID));
		this.setUserName(cursor.getString(IDX_COL_USER_NAME));
		this.setPassword(cursor.getString(IDX_COL_PASSWORD));
		this.setStreetAddress(cursor.getString(IDX_COL_STREET_ADDRESS));
		this.setContact(cursor.getString(IDX_COL_CONTACT));
		this.setRole(cursor.getString(IDX_COL_ROLE));
		this.setCellNumber(cursor.getString(IDX_COL_CELL_NUMBER));
		return (T) this;
	}


	@Override
	public String getCreateTableQuery() {

		return AUTO_GEN_QUERY.getCreateTableQuery();
	}

	@Override
	public String getInsertQuery() {

		return AUTO_GEN_QUERY.getPreparedInsertQuery();
	}

	@Override
	public String getDeleteQuery() {

		return AUTO_GEN_QUERY.getPreparedDeleteQuery();
	}

	@Override
	public String getUpdateQuery() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTableName() {

		return AUTO_GEN_QUERY.getTableName();
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getStreetAddress() {
		return streetAddress;
	}

	public void setStreetAddress(String streetAddress) {
		this.streetAddress = streetAddress;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public String getCellNumber() {
		return cellNumber;
	}

	public void setCellNumber(String cellNumber) {
		this.cellNumber = cellNumber;
	}

	@Override
	public ContentValues bindContentValues() {
		// TODO Auto-generated method stub
		return null;
	}

}
